// Tags:
#include <algorithm>
#include <cstdio>

typedef long long ll;
const int bit = 63, mod = 1e9 + 7;
ll n, m, ans, tmp;

inline ll calc(ll x, int i, bool typ) {
  if (x & (1ll << i))
    return typ ? (((x >> (i + 1))) % mod * ((1ll << i) % mod) % mod +
                  ((x & ((1ll << i) - 1)) + 1) % mod) %
                     mod
               : ((x >> (i + 1)) + 1) % mod * ((1ll << i) % mod) % mod;
  else
    return typ ? (x >> (i + 1)) % mod * ((1ll << i) % mod) % mod
               : (((x >> (i + 1))) % mod * ((1ll << i) % mod) % mod +
                  ((x & ((1ll << i) - 1)) + 1) % mod) %
                     mod;
}

inline ll solve(ll x, int i, bool typ) {
  static ll tmp;
  printf("%lld %d %d %lld\n", x, i, typ, tmp = calc(x, i, typ));
  return tmp;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("or_and.in", "r", stdin);
  freopen("or_and.out", "w", stdout);
#endif
#endif

  scanf("%lld%lld", &n, &m);
  if (n < m) std::swap(n, m);
  for (int i = bit - 1; ~i; --i) {
    if ((n < (1ll << i)) && (m < (1ll << i))) continue;
    tmp = 0;
    tmp += calc(n, i, false) * calc(m, i, true) % mod;
    if (tmp >= mod) tmp -= mod;
    tmp += calc(n, i, true) * ((m + 1) % mod) % mod;
    if (tmp >= mod) tmp -= mod;
    ans += tmp * ((1ll << i) % mod) % mod;
    if (ans >= mod) ans -= mod;
  }
  printf("%lld", ans);
  return 0;
}